//
//  HWVisitorTableViewController.swift
//  WeiBo
//
//  Created by macbook on 16/6/28.
//  Copyright © 2016年 buWangChuXing. All rights reserved.
//

import UIKit

class HWVisitorTableViewController: UITableViewController {

    //给访客视图添加一个属性
    let isLogin:Bool = false
    
   //访客视图属性
    var vistorViews:HWVistorView?
    
    override func loadView() {
        
        if isLogin {
            
            super.loadView()
        }else
        {
            setVistorView()
         }
        
        
    }
    
  
    //创建访客视图
    private func setVistorView(){
    
        //添加两个items
        setupNavBar()
        //在这里实现刚刚访客视图
        vistorViews = HWVistorView()
       
        //调用闭包 直接调用按钮的方法
        vistorViews?.colose = {[weak self] in
            
            self?.longinClick()
        
        }
        view = vistorViews
        
    }
    
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

     
    }
    
    
    
    
    
    //添加nav按钮
    private  func setupNavBar(){
    
        navigationItem.leftBarButtonItem  = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(HWVisitorTableViewController.longinClick))
        
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(HWVisitorTableViewController.longinClick))
    
    }
    
    //点击登陆和注册按钮跳转OAuth控制，进行第三方登陆
    func longinClick (){
        let OAuthVc = HWOAuthViewController()
        
        let navVc = UINavigationController(rootViewController: OAuthVc)
        
        self.presentViewController(navVc, animated: true, completion: nil)
     
    }
    
    
    
}
